package com.zhuxi.util;

import com.zhuxi.pojo.LoginRecords;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class GlobUtils {
    //存储登录记录
    public static List<LoginRecords> loginRecordsList = new ArrayList<>();
    //防刷时间(毫秒)
    public static long ipTime = 3 * 60 * 1000;
    //防刷次数
    public static int ipCount = 100;

    public static boolean isPass() {
        //判断前先清理过期数据
        Date now = new Date();
        if (loginRecordsList.size() != 0) {
            for (LoginRecords records : loginRecordsList) {
                if (now.getTime() - records.getLoginTime().getTime() > ipTime) {
                    loginRecordsList.remove(records);
                }
            }
        }
        return loginRecordsList.size()+1 > ipCount ? false : true;
    }
}
